package cn.tianyigps.tianyigpsyndistributetask.handler;

import cn.tianyigps.tianyigpskafka.task.manger.NewTaskManager;
import cn.tianyigps.tianyigpspublic.param.bo.Task;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: WEI.YUAN
 * @Descirption:
 * @Date: 2019/4/27_14:41
 */
@Component
@Slf4j
public class HandTaskHandler {
    @Autowired
    NewTaskManager newTaskManager;
    private static ObjectMapper OM = new ObjectMapper();
    /**
     * 任务下发
     * @param task
     */
    public void distributeTask(Task task) {
        try {
            newTaskManager.distributeTask(task.getType(),OM.writeValueAsString(task));
        } catch (Exception e) {
            e.printStackTrace();
            log.error("task反序列化异常");
        }

    }
}
